package com.baitengsoft.patentapimonitor.api.controller;

import com.baitengsoft.patentapimonitor.api.entity.WebUserinfoEntity;
import com.baitengsoft.patentapimonitor.api.model.WebUserMenuModel;
import com.baitengsoft.patentapimonitor.api.service.WebUserMenuService;
import com.baitengsoft.patentapimonitor.common.utils.Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by QEK on 2017/12/25.
 */

@RestController
@RequestMapping("/api/v1/web/webusermenu")
@Api(value = "前台-用户菜单管理",description = "用户菜单管理")
public class WebUserMenuController extends AbstractController{

    @Autowired
    private WebUserMenuService webUserMenuService;

    @ApiOperation(value = "获取用户菜单")
    @RequestMapping(value = "/querywebusermenu",method = RequestMethod.GET)
    public Res selectUserMenu(){
        WebUserinfoEntity userInfo = getUserInfo();
        if(userInfo != null ) {
            List<WebUserMenuModel> list = webUserMenuService.getUserMenuListByUserId(userInfo.getId());
            return Res.ok().put("webUserMenuList",list);
        }
        return Res.error("过期，请重新登录！");
    }

}
